using System;
using SimpleServiceBus.Bus.MessageManagement.Callbacks;
using SimpleServiceBus.Bus.Pipeline;
using SimpleServiceBus.Endpoint;
using SimpleServiceBus.Utilities;

namespace SimpleServiceBus.Bus
{
    /// <summary>
    /// Defines a bus to be used with SimpleServiceBus.
    /// </summary>
    public interface IMessageBus : IEndpointService
    {
        event EventHandler<MessageProcessingErrorEventArgs> MessageProcessingException;

        event EventHandler<MessageProcessingEventArgs> BeginReceiveMessage;
        event EventHandler<MessageProcessingEventArgs> MessageReceived;

        event EventHandler<MessageProcessingEventArgs> BeginSendMessage;
        event EventHandler<MessageProcessingEventArgs> MessageSent;
        
        void Publish(object message);
        void Subscribe<T>();
        void Unsubscribe<T>();

        string ReturnAddress { get; }


        void SendLocal(object message);

        ICallback Send(object message);
        ICallback Send(object message, params string[] destinations);

        void Reply(object message);

        void Forward(MessageEnvelope messageEnvelope, params string[] destinations);


        //void HandleCurrentMessageLater();
    }
}